#!/bin/bash

basepath=$(readlink -f $(dirname $0))
#source $basepath/00_docker_name.sh
dockerName=mysql

mkdir -p /opt/docker/mysql
mkdir -p /opt/docker/data
mkdir -p /opt/docker/conf

#docker pull mysql:8.0.20
docker pull mysql:8.4.2
docker run -d --name $dockerName --restart=always \
-v /opt/docker/mysql/data/:/var/lib/mysql \
-v /opt/docker/mysql/conf/my.cnf:/etc/mysql/my.cnf \
-p 3301:3306 \
-e MYSQL_ROOT_PASSWORD=testYnlcom \
mysql:8.4.2


#上面的可能不成功，可以采用如下的方法

#docker run -d --name $dockerName --restart=always \
 #-v /opt/docker/mysql/data/:/var/lib/mysql \
 #-v /opt/docker/mysql/conf/:/etc/mysql/conf.d/ \
 #-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
 #-p 3301:3306 \
 #mysql:8.4.2

#docker_exec mysql /bin/bash
 #
 #mysql -uroot
 #
 #use mysql;
 #
 #ALTER USER 'root'@'%' IDENTIFIED BY 'testYnlcom' PASSWORD EXPIRE NEVER;
 #ALTER USER 'root'@'localhost' IDENTIFIED BY 'testYnlcom' PASSWORD EXPIRE NEVER;